﻿CREATE TABLE [dbo].[tblSequenceOrder] (
    [SequenceOrderID]    INT      IDENTITY (1, 1) NOT NULL,
	[CustomerID]		int NOT NULL,
    [OrderID]            INT      NULL,
    [SequenceID]         INT      NULL,
    [CanceledReasonID] 	int NULL,
	[CanceledDate]		 SMALLDATETIME NULL,
    [OwnerID]            INT      NOT NULL,
	[SequenceStatusCode]	char(1)	not null,
	[AccountID]			INT null,
	[ShipTo_PersonID]	INT null,
	[ShipTo_CompanyName] NVARCHAR(50)	null,
	[ShipTo_AddressID]	INT		null,
	[CreateDate]		smalldatetime null
);
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'Defines the root of a single sequence for a customer.  If the sequence is generated from a sequence definition then SequenceID will point to it.  If the sequence is generated from a trigger order the OrderID will point to it', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'Points to the sequence definition which this sequence was generated from', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'SequenceID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'Points to the trigger order that triggered the generation of this sequence.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'OrderID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'Points to Account information used in billing generated orders', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'AccountID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'The date this sequence was canceled or NULL.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'CanceledDate';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'The reason code that the sequence was canceled or NULL', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'CanceledReasonID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'The PresonID of the ship-to address for generated orders', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'ShipTo_PersonID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'The AddressID of the Ship-to for the generated orders.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'ShipTo_AddressID';
GO;
EXECUTE sp_addextendedproperty @name = N'MS_Description', 
	@value = N'The CompanyName for the Ship-to for the generated orders.', 
	@level0type = N'SCHEMA', @level0name = N'dbo',
	@level1type = N'TABLE', @level1name = N'tblSequenceOrder',
	@level2type = N'COLUMN', @level2name = N'ShipTo_CompanyName';
